--on getBehaviorDescription me -- return \ -- "CUSTOM SCROLL BAR" & RETURN & RETURN & \ -- "Create dynamic scrollbars with your own artwork. " & \ -- " Such scrollbars are not Direct-To-Stage, so other sprites can appear over the top of them." & RETURN & RETURN & \ -- "You will need to create four graphic members:" & RETURN & \ -- "+ up arrow" & RETURN & \ -- "+ down arrow" & RETURN & \ -- "+ dragger" & RETURN & \ -- "+ backing bar" & RETURN & RETURN & \ -- "You may wish to use two additional members, to indicate that the arrow buttons have been pressed:" & RETURN & \ -- "+ up arrow (pressed state)" & RETURN & \ -- "+ down arrow (pressed state)" & RETURN & RETURN & \ -- "Place the four standard members on the Stage, and drop this behavior onto each of them. " & \ -- " Choose how the current sprite is to act in the appropriate pop-up menu in the Behavior Parameters dialog." & RETURN & RETURN & \ -- "For each element you can choose whether animations should continue in the background. " & \ -- " This option will tend to slow both the animations and the scrolling process, especially if applied to the arrow buttons." & RETURN & RETURN & \ -- "The various sprites will position themselves automatically to the right of the sprite-to-be-scrolled when the movie runs. " & \ -- " They revert to their original positions when it stops. " & \ -- " To avoid flashes, it would be a good idea to position them by hand in their intended positions." & RETURN & RETURN & \ -- "If you use a border on your field members, the scrollbar will sit outside the border. " & \ -- " Field box shadows are not recommended. " & \ -- " You can always fake external borders and box shadows with shape members (this even gives you a choice of colors)." & RETURN & RETURN & \ -- "To make authoring easier, this behavior will continue to work if you change EITHER the sprite channel OR the member in the chosen channel. " & \ -- " If you change both, the behavior will no longer know what to scroll." & RETURN & RETURN & \ -- "If you do change either the sprite or the member, and then reopen the Behavior Parameters dialog for one of the elements, this will put that behavior out of synch with the others. " & \ -- " Simply reopen and close the Parameters dialogs for each of the other elements. " & \ -- " If you do not do so, you will receive multiple alerts." & RETURN & RETURN & \ -- "This behavior can be used to scroll both editable and non-editable Fields and Text members. " & \ -- " For editable members, however, it does not automatically update the dragger position when the length of the text changes, nor does it make the editable member scroll automatically when the user drags the mouse to create a selection." & RETURN & RETURN & \ -- "PERMITTED MEMBER TYPES:" & RETURN & \ -- "[#animGif, #bitmap, #filmLoop, #flash, #movie, #picture, #shape]" & RETURN & RETURN & \ -- "PARAMETERS:" & RETURN & \ -- "* Current sprite acts as (up|down arrow | dragger | bar)" & RETURN & \ -- "* Scroll the member of : " & RETURN & \ -- "* Standard member (this should not need to be set)" & RETURN & \ -- "* Member to display when arrow buttons are pressed" & RETURN & \ -- "* Allow animations to continue" & RETURN & RETURN & \ -- "PUBLIC METHODS" & RETURN & \ -- "=> Scroll the text/field member to a given position" & RETURN & \ -- "=> Swap the text/field member to be scrolled" & RETURN & \ -- "=> Get the behavior reference" --end getBehaviorDescription -- NOTES FOR DEVELOPERS -- This is the most complex behavior I have written for the Behavior Library. -- I have included in one script all the handlers necessary to deal with each -- of the four elements of a scroll bar. -- -- In practice, this one script works as four separate behaviors. Each element -- is identified by its myScrollRole (upArrow, downArrow, dragger or bar). The -- behavior acts differently for each myScrollRole. Many handlers are divided -- into section by a "case myScrollRole of" statement. -- INSTALLATION -- Initializing the 4 behaviors cannot be done all at once on beginSprite -- because the behaviors on the other sprites may not exist. To get round -- this, I set a myState property to 0 in the StartInstallation handler -- (on beginSprite). The first prepareFrame (which is sent once all behaviors -- in the current frame have been instanciated) sees that "myState + 0 = 0" -- (or FALSE) and calls the FinishInstallation handler. -- Why "myState + 0"? Because once the installation is finished, myState is -- set to #done. This is a symbol. A symbol is simply an integer with a -- special tag. Adding zero to a symbol gives you access to the integer -- itself. Later, when the prepareFrame handler encounters "#done + 0" it -- evaluates this as a positive integer (or TRUE) and doesn't botherd to -- reinstall the elements. -- This technique is excessively fast: it slows down the following -- prepareFrames by something in the order of a millionth of a second. -- Installation itself is a three step-process. -- First: the behavior has to check if the sprite and member that it is to -- scroll do actually appear where it expects to find them. The -- ourScrolledElement property returned by the getPropertyDescriptionList -- handler is a double-barreled affair: "sprite X:field(member Y of castLib Z)". -- If sprite X contains a Field or Text member, the behavior assumes that this -- is the right one, and adopts it as myScrolledMember. If not, it sets out to -- look for (member Y of castLib Z), via the FindSprite handler. If it finds -- this member in one of the sprites in the frame, then it adopts the new -- sprite as myScrolledSprite. If not, it warns the author (4 times, once for -- each behavior). -- Second: the current behavior has to check if all the others are present. -- The Initialize handler has already prepared a list of all behaviors which -- treat the same sprite and/or member: ourControlList. The CheckControl -- handler ensures that this list contains one behavior for each control -- element... and only one. -- Third: the sprite to which the behavior is attached has to be placed -- correctly beside the sprite it is to scroll. This is most complex for the -- Dragger sprite, since it must be placed in accordance with the current -- scrollTop of myScrolledMember. -- The scrolling itself is always carried out by the behavior attached to the -- dragger. The Move and MoveBar handlers (which deal with clicks on the arrow -- buttons and on the backing bar) end with a... -- -- call (#SetDraggerShift, ourControlList.dragger) -- -- ... command. The bar behavior must in addition ask the dragger where it now -- is, using "call (#GetDraggerData, ourControlList.dragger)", so as to update its -- myActiveZone. -- EXTERNAL LINGO CALLS -- * CustomScrollbar_SetScroll me, theScroll -- If you use standard Lingo to set the scrollTop of myScrolledMember at -- runtime, the dragger position will not update until the scroll bar is next -- used. Use this call to tell the dragger to do all the work for you -- * CustomScrollbar_SwapMember me, newMember, currentMemberOrSprite -- If you use standard Lingo to swap the member of myScrolledSprite at runtime, -- the behaviors will continually happily to scroll the member which is now -- off-stage. Use this call to tell one of the behaviors do the swapping for -- you. -- * CustomScrollbar_GetReference me, memberOrSprite, controlOrList -- Using sendAllSprites with one of the above messages will ensure that the -- job gets done... four times, once by each behavior that makes up the -- scroll bar. If you call one of the behaviors directly, the command will be -- executed just once. But first you must get an object reference to the -- behavior in question. The following syntax is the simplest: -- -- scrollRef = sendAllSprites (#CustomScrollbar_GetReference, sprite X) -- -- This will give you a reference to the behavior on the highest sprite which -- controls the scrolling of sprite X. -- More details on using these external calls are given in the handlers -- themselves. -- HISTORY -- -- 27 October 1998: written for the D7 Behaviors Palette by James Newton -- 24 November 1998: vector shapes abandoned as permitted members -- 12 january 2000: Added isOKToAttach and removed unneeded error checking.